package com.nbsaas.boot.cms.rest.convert;

import com.nbsaas.boot.cms.data.entity.NewsCatalog;
import com.nbsaas.boot.cms.api.domain.request.NewsCatalogRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.cms.data.entity.NewsCatalog;

/**
* 新闻分类请求对象转换成实体对象
*/

public class NewsCatalogEntityConvert  implements Converter<NewsCatalog, NewsCatalogRequest> {

    @Override
    public NewsCatalog convert(NewsCatalogRequest source) {
        NewsCatalog result = new NewsCatalog();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getParent()!=null){
                    NewsCatalog parent =new NewsCatalog();
                    parent.setId(source.getParent());
                    result.setParent(parent);
                    }
        return result;
    }
}

